package com.pattern.observer;

import org.junit.Test;

public class TestObserver {

	@Test
	public void test1(){
		//1.创建目标对象
		SubjectImpl subject = new SubjectImpl();
		subject.setMessage("我要买车啦！");
		//2.创建观察者对象
		ObserverImpl observer1= new ObserverImpl("A");
		ObserverImpl observer2= new ObserverImpl("B");
		ObserverImpl observer3= new ObserverImpl("C");
		ObserverImpl observer4= new ObserverImpl("D");
		ObserverImpl observer5= new ObserverImpl("E");
		//3.注册观察者
		subject.attach(observer1);
		subject.attach(observer2);
		subject.attach(observer3);
		subject.attach(observer4);
		subject.attach(observer5);	
		//4.目标发布服务
		subject.notifyObservers();
		
	}
	
	
	public static void main(String[] args) {

	}

}
